package tutorial;

import gui.RiskGUI;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import resources.images.ImagesPath;

import com.swtdesigner.SWTResourceManager;

public class Finish implements TutorialWindow {

	private Label hereYouAreText;
	protected Object result;
	protected Shell shell;
	protected Shell parent;
	private Tutorial tutorial;

	/**
	 * Create the dialog
	 * @param parent
	 * @param tutorial 
	 */
	public Finish(Shell parent, Tutorial tutorial) {
		this.parent = parent;
		this.tutorial = tutorial;
	}

	/**
	 * Open the dialog
	 * @return the result
	 */
	public void open() {
		createContents();
		shell.open();
		shell.layout();
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(parent, SWT.DIALOG_TRIM);
		shell.addShellListener(new ShellAdapter() {
			public void shellClosed(final ShellEvent e) {
				tutorial.endTutotial();
			}
		});
		shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
		shell.setBackgroundImage(new Image(Display.getDefault(), ImagesPath.getImageStream("tutorial_background.png")));
		shell.setLocation(parent.getBounds().width,0);
		shell.setSize(219, RiskGUI.display.getClientArea().height);
		shell.setText("Step five");

		final Label welcomeToRiskLabel = new Label(shell, SWT.CENTER);
		welcomeToRiskLabel.setBounds(0, 5, 213, 47);
		welcomeToRiskLabel.setForeground(SWTResourceManager.getColor(255, 0, 0));
		welcomeToRiskLabel.setFont(SWTResourceManager.getFont("Comic Sans MS", 20, SWT.NONE));
		welcomeToRiskLabel.setText("Congratulations");

		hereYouAreText = new Label(shell, SWT.WRAP);
		hereYouAreText.setBounds(10, 68, 193, 316);
		hereYouAreText.setText("You finished the tutorial... So, the only thing rest to do is- start playing.\nRememmber, at any time during the game, you are able to see this tutorial again. Simply click on the \"Tutorial\" option under the \"Help\" menu, or use the shortcut CTRL+T.\n\n\"The only way to win Risk, is take to take a risk...\"");
		hereYouAreText.setFont(SWTResourceManager.getFont("Comic Sans MS", 12, SWT.NONE));

		final Label label = new Label(shell, SWT.NONE);
		label.addMouseListener(new MouseAdapter() {
			public void mouseDown(final MouseEvent arg0) {
				tutorial.prvStep();
			}
		});
		label.setToolTipText("Move soldiers");
		label.setBackgroundImage(new Image(Display.getCurrent(), ImagesPath.getImageStream("left.gif")));
		label.setBounds(150, shell.getBounds().height-100, 58, 58);
		//
	}

	public Shell getShell() {
		return shell;
	}

}
